<?php

//创建websocket client对象
//$cli = new swoole_http_client("ws.coincap.io", 443, true);
//$cli = new swoole_http_client("wss://ws.jinse.com", 443, true);
$cli = new swoole_http_client("39.105.37.225", 443, true);
//$cli = new swoole_http_client("47.104.158.161", 9520);
//$cli = new swoole_http_client("ws://www.mumuhuli.com", 9520);

$cli->on('message', function ($_cli, $frame) {
    var_dump($frame->data);
});

//$cli->upgrade('/prices?assets=bitcoin', function ($cli) {
$cli->upgrade('/ws', function ($cli) {
//$cli->upgrade('/', function ($cli) {
    echo $cli->body;
    //{"event":"jinse","action":"sub","channel":"jinse_tick_update"}
    $cli->push('{"event":"jinse","action":"sub","channel":"jinse_tick_update"}');
    /*$data = [
        'event' => 'jinse',
        'action' => 'sub',
        'channel' => 'jinse_tick_update'
    ];
    $cli->push(json_encode($data));*/
});